package com.jinzhi.jzcultivate.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.ConsultationsDO;
import com.jinzhi.jzweb.service.ConsultationsService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@AllArgsConstructor
@RequestMapping("/notice")
public class NoticeController extends BaseController {

	@Autowired
	private ConsultationsService consultationsService;

	@Log("行业公告")
	@GetMapping("/allNotice")
	@ResponseBody
	Result<?> allNotice(String secondColumn , int current , int number){
		//-------------行业资讯-------------\\
		Page<ConsultationsDO> page = consultationsService.findList(current , number , secondColumn);

		return Result.ok(page);
	}
	@Log("资讯详情")
	@GetMapping("/newsInfo")
	String allNotice(Model model ,Long id ,String name){

		ConsultationsDO con = consultationsService.selectById(id);
		con.setAccessNumber(con.getAccessNumber() + 1);
		consultationsService.updateById(con);

		model.addAttribute("name" , name);
		model.addAttribute("con" , con);

		return "cultivateWeb/news/newsInfo";
	}

}
